<template>
	<view class="body">
		<view v-show="hosArr.length" class="uni-list-item"  v-for="(hos,hosIndex) in hosArr" :key="hosIndex">
			<label class="title">{{hos.AKB021}}</label>
			<view class="sub_title">
				<text>
					机构编码:{{hos.AKB020}} 
				</text>
				<text>
					医院等级:{{hos.AKA101_NAME}}
				</text>
			</view>
		</view>
		<view  class="pagination-wrap" v-show="hosArr.length" >
			<uni-tag :inverted="true" @click="turnUp(0)" text="上页" size="small"></uni-tag>
			<text  class="pageIndex">{{pageIndex}}/{{totalPage}}</text>
			<uni-tag :inverted="true" @click="turnUp(1)" text="下页" size="small"></uni-tag>
		</view>
		<view v-show="!hosArr.length"  class="uni-list-item">
			暂无数据
		</view>
	</view>
</template>

<script>
	import uniTag from '@/components/uni-tag/uni-tag.vue';
	export default {
		components: { uniTag },
		data() {
			return {
				id:'',
				name:'',
				hosArr:[],
				pageIndex:1,
				totalPage:1,
			}
		},
		methods: {
			turnUp(val){	
				if(this.pageIndex==1&&val==0){
					uni.showToast({
						title:'已是首页',
						image:'../../static/image/info.png'
					});
					return false;
				}
				if(this.pageIndex==this.totalPage&&val==1){
					uni.showToast({
						title:'已是尾页',
						image:'../../static/image/info.png'
					});
					return false;
				}
				if(this.pageIndex>1&&val==0){
					this.pageIndex--;
					if(this.pageIndex<1){
						this.pageIndex = 1;
					}
					this.getData();
				}
				
				if(this.pageIndex<this.totalPage&&val==1){
					this.pageIndex++;
					if(this.pageIndex>this.totalPage){
						this.pageIndex=this.totalPage;
					}
					this.getData();
				}
				
				
			},
			getData(){
				var self = this;
				this.$request('S1007',{AKC801:this.id,AKB021:this.name,PAGENUM:this.pageIndex,PAGESIZE:15},'POST',function(resList){
					if(resList.data.CODE=='0'&&resList.data.DATA.length){
						self.totalPage = resList.data.PAGESIZECOUNT;
						self.hosArr = resList.data.DATA;
					}
				})
			}
		},
		onLoad(params){
			this.id = _.trim(params.id);
			this.name =  _.trim(params.name);
			console.log(params)
			this.getData();
		}
	}
</script>

<style>
.uni-list-item {
		width: auto;
		margin-bottom: 10upx;
		font-size: 16px;
		color: #606266 !important;
		line-height: 30px;
	}
</style>
